States of India and a demonstration of the 4 colour theorem

library("leaflet")
library("rgdal")
## Loading required package: sp
## rgdal: version: 1.2-16, (SVN revision 701)
##  Geospatial Data Abstraction Library extensions to R successfully loaded
##  Loaded GDAL runtime: GDAL 2.2.0, released 2017/04/28
##  Path to GDAL shared files: C:/Users/cd7bha/Documents/R/win-library/3.4/rgdal/gdal
##  GDAL binary built with GEOS: TRUE 
##  Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
##  Path to PROJ.4 shared files: C:/Users/cd7bha/Documents/R/win-library/3.4/rgdal/proj
##  Linking to sp version: 1.2-5
library("ggmap")
## Loading required package: ggplot2
library("raster")
library("htmlwidgets")

states <- readOGR("IndiaAdminUnits/States.shp")
## OGR data source with driver: ESRI Shapefile 
## Source: "IndiaAdminUnits/States.shp", layer: "States"
## with 36 features
## It has 1 fields
colourIndex = c(1,1,1,2,2,3,2,3,1,3,2,2,3,2,3,2,1,1,3,1,1,1,3,3,3,2,1,4,2,3,3,1,1,4,1,4)
areas <- c(8249, 162968, 83743, 78438, 94163, 114, 135191, 491, 112, 3702, 196024, 44212, 55673, 222236, 79714, 191791, 38863, 32, 308350, 307713, 22327, 22429, 21081, 16579, 1484, 562, 50362, 342239, 7096, 130058, 112077, 10486, 243290, 53483, 88752, 155707)
states[["Area"]] <- areas
colors4 <- c("#3300FF", "#CCFF00", "#00B3FF", "#FF0000")

states[["ColourIndex"]] <- colourIndex

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.